import { getBuildingList } from './api';
import { Dispatch } from 'redux';
import type { IBuildingParam } from './index.d'

export const MODULE_NAME: string = 'workbench';

export const types = {
  DATA_SOURCE: `${MODULE_NAME}/DATA_SOURCE`, // 列表数据
}

export default (state: any = {
  dataSource: []
}, action: any) => {
  switch (action.type) {
    case types.DATA_SOURCE:
      return Object.assign({}, state, {
        dataSource: action.data
      })
    default: return state
  }
}

/**
 * 获取列表数据
*/
export const getList = (params: IBuildingParam) => {
  return async (dispatch: Dispatch): Promise<void> => {
    try {
      const res = await getBuildingList(params);

      // dispatch(res.data)
      console.log(res.data)
    } catch { }
  }
}
